package com.wondertek.poms.dao.po;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.Proxy;
import org.springframework.format.annotation.DateTimeFormat;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.wondertek.poms.common.constant.CurrentUser;

import lombok.Data;

/**
 * 节目移动历史记录
 * 释放规则
 * @author chyx
 */
@Data
@Entity
@Table(name = "move_cont_log")
@DynamicUpdate
@DynamicInsert
@Proxy(lazy = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class MoveContLog implements Serializable {
	private static final long serialVersionUID = -5220976865722504516L;
	@Id
	@Column(name = "id")
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "move_cont_log_seq")
	@SequenceGenerator(name = "move_cont_log_seq", allocationSize = 1, sequenceName = "move_cont_log_seq")
	private Long id;
	
	@Column(name = "prd_cont_id")
	private Long prdContId;//节目ID
	
	@Column(name = "content_id")
	private String contentId;//内容ID
	
	@Column(name = "old_prd_info_id")
	private Long oldPrdInfoId;//老产品包ID
	
	@Column(name = "new_prd_info_id")
	private Long newPrdInfoId;//新产品包ID
	
	@Column(name = "operator")
	private String operator;//操作人员
	
	@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@Column(name = "create_time")
	private Date createTime;//操作时间
	
	@Column(name = "CONTENT_NAME")
	private String contentName;//内容名称
	
	@Column(name = "FIRST_PRDINFO_PACKAGE")
	private Long firstPrdInfoPackage;//一级产品ID
	
	@Column(name = "SECOND_PRDINFO_PACKAGE")
	private Long secondPrdInfoPackage;//二级产品ID
	
	/**
     * <b>Fields</b> newPrdInfoName : 新商品包名称
     */
	@Transient
    private String newPrdInfoName;
	
	/**
     * <b>Fields</b> oldPrdInfoName : 老商品包名称
     */
	@Transient
    private String oldPrdInfoName;
    
    /**
     * <b>Fields</b> firstPrdInfoPackageName : 一级产品名称
     */
	@Transient
    private String firstPrdInfoPackageName;
    
    /**
     * <b>Fields</b> secondPrdInfoPackageName : 二级产品名称
     */
	@Transient
    private String secondPrdInfoPackageName;
    
	@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@Transient
	private Date startTime;//开始时间
	
	@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@Transient
	private Date endTime;//结束时间
	
	public static void putTimeAndUser(MoveContLog mcLog) {
		if (mcLog.id == null) {
			mcLog.setOperator(CurrentUser.currUserName());
			mcLog.setCreateTime(new Date());
		}
	}
}
